<?php
    header("content-type:text/html;charset=utf-8");
    session_start();
    $config = include_once('../../public/config/config.php');
    include_once('../../public/func/db.php');
    $res = select($config,'user','where uname ="'.$_POST['uname'].'"');
    if(empty($res)){
        die("<script>alert('请先注册！');window.location.href='/home/login/register.php'</script>");
    }else if(md5($_POST['pwd']) != $res[0]['pwd']){
        die("<script>alert('密码输入错误！');window.location.href='/home/login/login.php'</script>");
    }else{
            $_SESSION = array('uname'=>$_POST['uname'],'pwd'=>$_POST['pwd']);
        die("<script>alert('登录成功！');window.location.href='/home/index.php'</script>");
    }
?>